home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / tiff / libtiff / tiffcompat.h < prev    next >
C/C++ Source or Header  |  1992-03-30  |  6KB  |  217 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcompat.h,v 1.21 92/03/30 18:31:03 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1990, 1991, 1992 Sam Leffler
  5.  * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _COMPAT_
  28. #define    _COMPAT_
  29. /*
  30.  * This file contains a hodgepodge of definitions and
  31.  * declarations that are needed to provide compatibility
  32.  * between the native system and the base UNIX implementation
  33.  * that the library assumes (~4BSD).  In particular, you
  34.  * can override the standard i/o interface (read/write/lseek)
  35.  * by redefining the ReadOK/WriteOK/SeekOK macros to your
  36.  * liking.
  37.  *
  38.  * NB: This file is a mess.
  39.  */
  40. #if (defined(__STDC__) || defined(__EXTENDED__)) && !defined(USE_PROTOTYPES)
  41. #define    USE_PROTOTYPES    1
  42. #define    USE_CONST    1
  43. #endif
  44.  
  45. #if !USE_CONST && !defined(const)
  46. #define    const
  47. #endif
  48.  
  49. #ifdef THINK_C
  50. #include <unix.h>
  51. #include <math.h>
  52. #endif
  53. #if USE_PROTOTYPES
  54. #include <stdio.h>
  55. #endif
  56. #ifndef THINK_C
  57. #include <sys/types.h>
  58. #endif
  59. #ifdef VMS
  60. #include <file.h>
  61. #include <unixio.h>
  62. #else
  63. #include <fcntl.h>
  64. #endif
  65. #if defined(THINK_C) || defined(applec)
  66. #include <stdlib.h>
  67. #endif
  68.  
  69. /*
  70.  * Workarounds for BSD lseek definitions.
  71.  */
  72. #if defined(SYSV) || defined(VMS)
  73. #if defined(SYSV)
  74. #include <unistd.h>
  75. #endif
  76. #define    L_SET    SEEK_SET
  77. #define    L_INCR    SEEK_CUR
  78. #define    L_XTND    SEEK_END
  79. #endif
  80. #ifndef L_SET
  81. #define L_SET    0
  82. #define L_INCR    1
  83. #define L_XTND    2
  84. #endif
  85.  
  86. /*
  87.  * SVID workarounds for BSD bit
  88.  * string manipulation routines.
  89.  */
  90. #if defined(SYSV) || defined(THINK_C) || defined(applec) || defined(VMS)
  91. #define    bzero(dst,len)        memset((char *)dst, 0, len)
  92. #define    bcopy(src,dst,len)    memcpy((char *)dst, (char *)src, len)
  93. #define    bcmp(src, dst, len)    memcmp((char *)dst, (char *)src, len)
  94. #endif
  95.  
  96. /*
  97.  * The BSD typedefs are used throughout the library.
  98.  * If your system doesn't have them in <sys/types.h>,
  99.  * then define BSDTYPES in your Makefile.
  100.  */
  101. #ifdef BSDTYPES
  102. typedef    unsigned char u_char;
  103. typedef    unsigned short u_short;
  104. typedef    unsigned int u_int;
  105. typedef    unsigned long u_long;
  106. #endif
  107.  
  108. /*
  109.  * Return an open file descriptor or -1.
  110.  */
  111. #if defined(applec) || defined(THINK_C)
  112. #define    TIFFOpenFile(name, mode, prot)    open(name, mode)
  113. #else
  114. #if defined(MSDOS)
  115. #define    TIFFOpenFile(name, mode, prot)    open(name, mode|O_BINARY, prot)
  116. #else
  117. #define    TIFFOpenFile(name, mode, prot)    open(name, mode, prot)
  118. #endif
  119. #endif
  120.  
  121. /*
  122.  * Return the size in bytes of the file
  123.  * associated with the supplied file descriptor.
  124.  */
  125. #if USE_PROTOTYPES
  126. extern    long TIFFGetFileSize(int fd);
  127. #else
  128. extern    long TIFFGetFileSize();
  129. #endif
  130.  
  131. #ifdef MMAP_SUPPORT
  132. /*
  133.  * Mapped file support.
  134.  *
  135.  * TIFFMapFileContents must map the entire file into
  136.  *     memory and return the address of the mapped
  137.  *     region and the size of the mapped region.
  138.  * TIFFUnmapFileContents does the inverse operation.
  139.  */
  140. #if USE_PROTOTYPES
  141. extern    int TIFFMapFileContents(int fd, char **paddr, long *psize);
  142. extern    void TIFFUnmapFileContents(char *addr, long size);
  143. #else
  144. extern    int TIFFMapFileContents();
  145. extern    void TIFFUnmapFileContents();
  146. #endif
  147. #endif
  148.  
  149. /*
  150.  * Mac workaround to handle the file
  151.  * extension semantics of lseek.
  152.  */
  153. #ifdef applec
  154. #define    lseek    mpw_lseek
  155. extern long mpw_lseek(int, long, int);
  156. #else
  157. extern    long lseek();
  158. #endif
  159.  
  160. /*
  161.  * Default Read/Seek/Write definitions.
  162.  */
  163. #ifndef ReadOK
  164. #define    ReadOK(fd, buf, size)    (read(fd, (char *)buf, size) == size)
  165. #endif
  166. #ifndef SeekOK
  167. #define    SeekOK(fd, off)    (lseek(fd, (long)off, L_SET) == (long)off)
  168. #endif
  169. #ifndef WriteOK
  170. #define    WriteOK(fd, buf, size)    (write(fd, (char *)buf, size) == size)
  171. #endif
  172.  
  173. #if defined(__MACH__) || defined(THINK_C)
  174. extern    void *malloc(size_t size);
  175. extern    void *realloc(void *ptr, size_t size);
  176. #else /* !__MACH__ && !THINK_C */
  177. #if defined(MSDOS)
  178. #include <malloc.h>
  179. #else /* !MSDOS */
  180. #if defined(_IBMR2)
  181. #include <stdlib.h>
  182. #else /* !_IBMR2 */
  183. extern    char *malloc();
  184. extern    char *realloc();
  185. #endif /* _IBMR2 */
  186. #endif /* !MSDOS */
  187. #endif /* !__MACH__ */
  188.  
  189. /*
  190.  * dblparam_t is the type that a double precision
  191.  * floating point value will have on the parameter
  192.  * stack (when coerced by the compiler).
  193.  */
  194. #ifdef applec
  195. typedef extended dblparam_t;
  196. #else
  197. typedef double dblparam_t;
  198. #endif
  199.  
  200. /*
  201.  * Varargs parameter list handling...YECH!!!!
  202.  */
  203. #if defined(__STDC__) && !defined(USE_VARARGS)
  204. #define    USE_VARARGS    0
  205. #endif
  206.  
  207. #if defined(USE_VARARGS)
  208. #if USE_VARARGS
  209. #include <varargs.h>
  210. #define    VA_START(ap, parmN)    va_start(ap)
  211. #else
  212. #include <stdarg.h>
  213. #define    VA_START(ap, parmN)    va_start(ap, parmN)
  214. #endif
  215. #endif /* defined(USE_VARARGS) */
  216. #endif /* _COMPAT_ */
  217.